package demo1;

import java.util.*;

public class Main {

    public static void main1(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int left = 1, right = n;
        while(left <= right){
            System.out.print(left + " ");
            left++;
            if(left <= right){
                System.out.print(right + " ");
                right--;
            }
        }
    }

    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();

        TreeSet<Integer> set = new TreeSet<>();
        while(n-- != 0){
            set.add(in.nextInt());
        }
        while(m-- != 0){
            set.add(in.nextInt());
        }

        for(int x : set){
            System.out.print(x + " ");
        }
    }

    public static void main3(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();
        int[] arr1 = new int[n];
        int[] arr2 = new int[m];
        for(int i = 0; i < n; i++){
            arr1[i] = in.nextInt();
        }
        for(int i = 0; i < m; i++){
            arr2[i] = in.nextInt();
        }

        Arrays.sort(arr1);
        Arrays.sort(arr2);
        int t = 0, c1 = 0, c2 = 0;
        while(c1 < n && c2 < m){
            if(arr1[c1] < arr2[c2]){
                if(t != arr1[c1]){
                    t = arr1[c1];
                    System.out.print(t + " ");
                }
                c1++;
            }else{
                if(t != arr2[c2]){
                    t = arr2[c2];
                    System.out.print(t + " ");
                }
                c2++;
            }
        }

        while(c1 != n){
            if(t != arr1[c1]){
                t = arr1[c1];
                System.out.print(t + " ");
            }
            c1++;
        }
        while(c2 != m){
            if(t != arr2[c2]){
                t = arr2[c2];
                System.out.print(t + " ");
            }
            c2++;
        }
    }

    public static void main4(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] s = in.next().toCharArray();
        int n = s.length;
        int[][] dp = new int[n][n];

        for(int i = n - 1; i >= 0; i--){
            dp[i][i] = 1;
            for(int j = i + 1; j < n; j++){
                if(s[i] == s[j]){
                    dp[i][j] = dp[i + 1][j - 1] + 2;
                }else{
                    dp[i][j] = Math.max(dp[i + 1][j], dp[i][j - 1]);
                }
            }
        }
        System.out.print(dp[0][n - 1]);
    }
}
